<template>
	<view class="">


		<view class="shenbao">
			<view class="shenbao_title">
				活动报名
			</view>

			<!-- <view class="shenbao_flex" style="position: relative;">
				<picker style="width: 100%;height: 100%;line-height: 90rpx;" mode="date" start="2021-09-01"
					end="2022-09-01" @change="bindDateChange">
					<view class="">
						活动时间：
					</view>
					<view class="shenbao_flex_right"
						style="position: absolute;left: 265rpx;top: 50%;transform: translateY(-50%);color: #666;">
						<view class="" v-if="change==1">
							{{form.activitytime}}
						</view>
						<view class="" v-if="change==0">
							请选择活动时间
						</view>
					</view>

				</picker>

			</view> -->

			<!-- <view class="shenbao_flex" style="position: relative;">
				<picker style="width: 100%;height: 100%;line-height: 90rpx;"  mode="date" start="2021-09-01" end="2022-09-01" @change="bindDateChanges">
				  <view class="">
				  	活动结束时间：
				  </view>
				 <view class="shenbao_flex_right" style="position: absolute;left: 265rpx;top: 50%;transform: translateY(-50%);color: #666;">
				 		<view class="" v-if="changes==1">
				 			{{form.activitytimes}}	
				 		</view>		 
						<view class="" v-if="changes==0">
							请选择活动结束时间
						</view>
				 </view>
				</picker>
				
			</view> -->
			<view class="shenbao_flex" @click="chooseTime">
				<view class="">
					活动时间：
				</view>
				<view class="">
					<input disabled="true" class="shenbao_flex_right" v-model="time1" placeholder="请输入活动时间" type="text" value="" />
				</view>
			</view>
			<view class="shenbao_flex">
				<view class="">
					活动地址：
				</view>
				<view class="">
					<input class="shenbao_flex_right" v-model="form.address" placeholder="请输入活动地址" type="text"
						value="" />
				</view>
			</view>
			<view class="shenbao_flex">
				<view class="">
					目标曝光：
				</view>
				<view class="">
					<input class="shenbao_flex_right" v-model="form.baoguang" placeholder="请输入曝光数量" type="text" value="" />
				</view>
			</view>
			<view class="shenbao_flex">
				<view class="">
					目标线索：
				</view>
				<view class="">
					<input class="shenbao_flex_right" v-model="form.xiansuo" placeholder="请输入线索数量" type="text"
						value="" />
				</view>
			</view>
			<!-- <view class="shenbao_flex">
				<view class="">
					所属门店：
				</view>
				<view class="">
					<input class="shenbao_flex_right" v-model=""  placeholder="请输入所属门店名称" type="text" value="" />
				</view>
			</view> -->

			<view class="shenbao_flex">
				<view class="">
					目标A卡：
				</view>
				<view class="">
					<input class="shenbao_flex_right" v-model="form.aka" placeholder="请输入A卡数量" type="text" value="" />
				</view>
			</view>
			<view class="shenbao_flex">
				<view class="">
					目标订单：
				</view>
				<view class="">
					<input class="shenbao_flex_right" v-model="form.dingdan" placeholder="请输入订单数量" type="text" value="" />
				</view>
			</view>
			<view class="shenbao_flex">
				<view class="">
					其他：
				</view>
				<view class="">
					<input class="shenbao_flex_right" v-model="form.qita" placeholder="请输入其他" type="text" value="" />
				</view>
			</view>
			<view class="button_bottom" @click="onButton">
				确定提交
			</view>
		</view>
		<!-- <uni-popup ref="popup" type="bottom">
			<view class="time_tan">
				
				
			</view>
		</uni-popup> -->
         <!--  时间选择picker -->
		<w-picker :visible.sync="visible" mode="range" startYear="2021" endYear="2025" value="2021-01-01"
			:current="true" fields="day" @confirm="onConfirm($event,'date')" @cancel="onCancel" :disabled-after="false"
			ref="date">
			<view class="time_title">
				<view class="">
					开始时间
				</view>
				<view class="">
					结束时间
				</view>
			</view>
		</w-picker>

	</view>
</template>

<script>
	import {
		declaration
	} from '@/request/api.js'
	export default {
		data() {
			return {
				form: {
					// 曝光
					baoguang: 0,
					// 线索
					xiansuo: 0,
					// 经销商id
					distributor_id: '',
					// 区域代理id
					region_id: '',
					// 门店id
					store_id: '',
					// 活动id
					activity_id: '',
					// 活动开始时间
					activitytime: '',
					// 活动结束时间
					endtime:'',
					// 地址
					address: '',
					// activitytimes: '',
					// A卡
					aka:0,
					// 订单
					dingdan:0,
					// 其他
					qita:''
					// id:'2',
				},
				
				// shijian: '请选择活动地址',
				show: true,
				change: 0,
				changes: 0,
				showTimePopup: false,
				visible: false,
				time1: ''// 活动时间
			};
		},
		onLoad(option) {
			console.log(option);
			this.form.activity_id = option.id
			this.onlodeList()
		},
		onShow() {

		},
		onReady() {

		},
		methods: {
			chooseTime() {
				let that = this
				// that.$refs.popup.open('bottom')''
				that.visible = true
			},
			onConfirm(e) {
				console.log(e)
				let that = this
				that.time1 = e.result
				that.form.activitytime=e.value[0]
				that.form.endtime=e.value[1]
			},
			// bindDateChange: function(e) {
			// 	console.log('11111')
			// 	console.log('picker发送选择改变，携带值为', e.detail.value)
			// 	this.form.activitytime = e.detail.value
			// 	console.log(this.shijian)
			// 	this.change = 1
			// },
			// bindDateChanges: function(e) {
			// 	console.log('11111')
			// 	console.log('picker发送选择改变，携带值为', e.detail.value)
			// 	this.form.activitytimes = e.detail.value
			// 	console.log(this.shijian)
			// 	this.changes = 1
			// },
			onlodeList() {
				this.form.distributor_id = uni.getStorageSync("login").id
				this.form.region_id = uni.getStorageSync("login").regional_id
				this.form.store_id = uni.getStorageSync("login").store

			},
			onButton() {
				if (this.form.activitytime == '' || this.form.activitytimes == '' || this.form.activitytime == '' || this
					.form.address == '') {
					uni.showToast({
						title: "请填写完整信息",
						icon: "none"
					})
					return
				}
				declaration(this.form).then(res => {
					console.log(res);
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
					if (res.code == 1) {
						setTimeout(() => {
							uni.reLaunch({
								url: "/pages/DLR/activity/activity"
							})
						}, 2000)
					}
				})


			}

		}
	}
</script>

<style lang="scss">
	.time_title {
		width: 100%;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;
		position: fixed;
		top: 0;
		left: 0;
		padding: 20rpx 0;
	}
/deep/	.uni-picker-view-content{
		// padding: 130rpx 0 !important;
	}
	/deep/ .w-picker-view {
		height: 630rpx !important;
		padding: 20rpx 0;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
	}

	/deep/ .uni-picker-view-wrapper {
		padding: 0 40rpx;
	}

	/deep/ .w-picker-header {

		position: absolute !important;
		bottom:20rpx;
		left: 0;
		width: 100%;
		justify-content: space-around !important;
		height: 44rpx;
		z-index: 999;
		background-color: pink;
		border-bottom: none !important;
	}

	/deep/ .w-picker-cnt {

		border-radius: 24rpx 24rpx 0rpx 0rpx;
	}

  /deep/ text {
		width: 180rpx;
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border: 2rpx solid #1855F6;
		border-radius: 30rpx;

		&:nth-child(1) {
			color: #1855F6;
		}

		&:nth-child(3) {
			color: #fff !important;
			background-color: #1855F6;
		}
	}

	.shenbao {
		width: 670rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(211, 213, 220, 0.4);
		border-radius: 32rpx;
		margin: 0 auto;
		margin-top: 30rpx !important;
		padding: 25rpx 25rpx 80rpx 25rpx;
	}

	.shenbao_title {
		font-size: 38rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #313233;
		width: 100%;
		text-align: center;
		margin-bottom: 30rpx;
	}

	.shenbao_flex {
		display: flex;
		font-size: 36rpx;
		align-items: center;
		height: 90rpx;
		justify-content: space-between;
		border-bottom: 1rpx solid rgb(232, 232, 235);
		margin-bottom: 12rpx;
	}

	.shenbao_flex_right {
		width: 400rpx;
		font-size: 26rpx;
	}

	.button_bottom {
		width: 460rpx;
		height: 80rpx;
		background: #1855F6;
		border-radius: 40rpx;
		text-align: center;
		line-height: 80rpx;
		margin: 0 auto;
		margin-top: 200rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		font-family: PingFang SC;

	}

	.time_tan {
		width: 100%;
		height: 500rpx;
		border-radius: 24rpx 24rpx 0px 0rpx;
		background-color: #fff;
	}
</style>
